-
Notifications
You must be signed in to change notification settings - Fork 49
feat(r): Add experimental nanoarrow_vctr to wrap a list of arrays
#461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
paleolimbot
merged 20 commits into
apache:main
from
paleolimbot:r-convert-chunked-finish
May 15, 2024
Merged
feat(r): Add experimental nanoarrow_vctr to wrap a list of arrays
#461
paleolimbot
merged 20 commits into
apache:main
from
paleolimbot:r-convert-chunked-finish
May 15, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #461 +/- ##
==========================================
+ Coverage 88.76% 89.09% +0.32%
==========================================
Files 82 89 +7
Lines 14633 15958 +1325
==========================================
+ Hits 12989 14217 +1228
- Misses 1644 1741 +97 ☔ View full report in Codecov by Sentry. |
|
Amazing work, great to see these changes rolling in in real time! |
34122dd to
8596a0a
Compare
paleolimbot
added a commit
to geoarrow/geoarrow-r
that referenced
this pull request
May 27, 2024
GeoArrow was the wrong place for this class...it's much better in nanoarrow! See apache/arrow-nanoarrow#461 for the implementation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the
nanoarrow_vctr, which is an R translation of the PythonArrayclass in nanoarrow's Python bindings. This is implemented like an Rfactor()in the sense that under the hood it is a sequence of integers (0:(array$length - 1)at the beginning) with attributes that give those integers context.This is implemented in such a way that it is "tacked on" to the existing conversions. The existing conversions do need a refactoring ( #392 ), but that is a heavy change for this point in the release cycle.
The only change needed to the existing conversion was a slight refactor of the "consume array stream" code that correctly gave each array in the stream its own R object to manage its lifecycle (before each array was "materialized" and then immediately released because no previous conversion code required an ArrowArray to live beyond the conversion.
The motivation for this change is converting GeoArrow extension types. In the geoarrow package, we implement an efficient conversion from a stream of arrays to various types of R-spatial objects (e.g., sf); however, we really don't want to invoke the default conversion for those types because they have awful performance (e.g., the multipolygon would be a
list(list(list(data.frame))))) and there's no need to invoke that number of R object conversions between the initial state (an arrow array) and the final state (an sfc column). The nanoarrow_vctr allows something like:A side-effect of this change is that we have an escape hatch for conversions that are lossy or contain types with no R equivalent.
A quick demo:
Created on 2024-05-10 with reprex v2.1.0